      SUBROUTINE RDREQMT1(LUREQMT,EXPNAME,MAXEXP,MAXREQEXP,KEYREQEXP,
     *    LUERR,IERR)
      IMPLICIT REAL*8 (A-H,O-Z)
C
C THIS ROUTINE IS PART OF THE TOSS REQUIREMENTS FILE READER PACKAGE. IT
C DOES ERROR CHECKS AS INDICATED BY THE COMMENTS BELOW.
C
C***********************************************************************
C
C BY C PETRUZZO GSFC/742  1/86
C        MODIFIED....
C
C***********************************************************************
C
      INCLUDE 'RDREQMT.INC'
C
      CHARACTER*8 EXPNAME(MAXEXP)
      INTEGER KEYREQEXP(MAXREQEXP)
C
C
      IERR = 0
C
C
C TOO MANY EXPERIMENT NAMES ?
C
      IF(MAXEXP.GT.MAXEXPMTS) THEN
C      THIS READER PACKAGE HAS INTERNAL ARRAYS LIMITING IT TO READING
C      FILES WITH MAXEXPMTS OR FEWER EXPERIMENTS. RDREQMT.INC SETS THE
C      MAX VIA PARAMETER MAXEXPMTS.
        STOP ' RDREQMT1. CODING ERROR. MAXEXP > MAXEXPMTS.  STOP.'
        END IF
C
C
C DUPLICATE EXPERIMENT NAMES ?
C (NECESSARY BECAUSE RDREQMT5 ASSUMES UNIQUE NAMES WERE ENTERED)
C
      IF(EXPNAME(1).NE.'ALL') THEN
        DO INAME=1,MAXEXP
          DO JNAME=INAME,MAXEXP
            IF(INAME.NE.JNAME         .AND.
     *         EXPNAME(INAME).NE.' '  .AND.
     *         EXPNAME(INAME).EQ.EXPNAME(JNAME)) THEN
              IERR = 4
              IF(LUERR.GT.0) WRITE(LUERR,9901)
     *          'CALLER HAS SPECIFIED DUPLICATE EXPERIMENT NAMES. ' // 
     *             ' NAME=' // EXPNAME(INAME)
              GO TO 9999
              END IF
            END DO
          END DO
        END IF
C
C
C ALL EXPERIMENT NAMES BLANK?
C
      NEXP = 0
      DO IEXP=1,MAXEXP
        IF(EXPNAME(IEXP).NE.' ') NEXP = NEXP + 1
        END DO
      IF(NEXP.EQ.0) THEN
        IERR = 4
        IF(LUERR.GT.0) WRITE(LUERR,9901)
     *        'CALLER HAS SPECIFIED ALL BLANK EXPERIMENT NAMES.'
        GO TO 9999
        END IF
C
C BAD LUREQMT VALUE ?
C
      IF(LUREQMT.LE.0) THEN
        IERR = 4
        IF(LUERR.GT.0) WRITE(LUERR,9901)
     *     'CALLER HAS SPECIFIED ZERO/NEGATIVE REQMTS FILE UNIT NUMBER.'
        GO TO 9999
        END IF
C
C
C INVALID KEYREQEXP VALUES ?
C
      DO I=1,MAXREQEXP
        IF(KEYREQEXP(I).LT.0 .OR. KEYREQEXP(I).GT.(MAXKEYS-1)) THEN
          IERR = 4
          IF(LUERR.GT.0) WRITE(LUERR,9901)
     *          'CALLER HAS SPECIFIED INVALID KEYREQEXP VALUES.',
     *          'SUSPECT A CODING ERROR IN THE CALLER.'
          GO TO 9999
          END IF
        END DO
C
C
C DUPLICATE KEYREQEXP VALUES ?
C
      DO I=1,MAXREQEXP
        DO J=I,MAXREQEXP
          IF(I.NE.J   .AND. KEYREQEXP(I).NE.0   .AND.
     *       KEYREQEXP(I).EQ.KEYREQEXP(J)) THEN
            IERR = 4
            IF(LUERR.GT.0) WRITE(LUERR,9901)
     *          'CALLER HAS SPECIFIED DUPLICATE KEYREQEXP VALUES.',
     *          'SUSPECT A CODING ERROR IN THE CALLER.'
            GO TO 9999
            END IF
          END DO
        END DO
C
C
 9999 CONTINUE
      RETURN
C
 9901 FORMAT(/,
     *   ' OBSERVATION REQUIREMENTS FILE READER(RDREQMT).',
     *       ' ERROR CONDITION.'/,
     *   (5X,A))    ! ERROR MESSAGE TEXT
      END
